package com.acme.bankapp.domine.bank;

public class CheckingAccount extends AbstractAccount {
    private double overdraft;

    public double getOverdraft() {
        return overdraft;
    }

    public CheckingAccount(final int id, final double amount,
            final double overdraft) {
        super(id, amount);
        this.overdraft = overdraft;
    }

    @Override
    public int withdraw(final double amount) {
        if (getBalance() + overdraft >= amount) {
            setBalance(getBalance() - amount);
            return 0;
        } else {
            System.out.println("Error CheckingAccount: "
                               + "balance + overdraft < amount");
            return -1;
        }
    }

    @Override
    public double maximumAmountToWithdraw() {
        return getBalance() + overdraft;
    }
}
